saveSWF {animation} | R Documentation |
This function opens a graphical device first to generate a sequence of images based on expr
, then makes use of the commands in `SWF Tools' (png2swf
, jpeg2swf
, pdf2swf
) to convert these images to a single Flash animation.
saveSWF(expr, interval = 1, swfname = "movie.swf", dev = c("png", "jpeg", "pdf"), filename = "Rplot", fmt = "%03d", outdir = tempdir(), swftools = NULL, para = par(no.readonly = TRUE), ...)
expr |
an expression to generate animations; use either the animation functions (e.g. brownian.motion() ) in this package or a custom expression (e.g. for(i in 1:10) plot(runif(10), ylim = 0:1) ). |
interval |
duration between animation frames (unit in seconds) |
swfname |
file name of the Flash file |
dev |
character: the graphics device to be used. Three choices are available: png , jpeg and pdf , etc. |
filename |
file name of the sequence of images (`pure' name; without any format or extension) |
fmt |
a C-style string formatting command, such as `%3d ' |
outdir |
the directory for the animation frames and the Flash file |
swftools |
the path of `SWF Tools', e.g. ‘C:/swftools’. This argument is to make sure that png2swf , jpeg2swf and pdf2swf can be executed correctly. If it is NULL , it should be guaranteed that these commands can be executed without the path. |
para |
a list: the graphics parameters to be set before plotting; passed to par |
... |
other arguments passed to the graphical device, such as height and width , ... |
An integer indicating failure (-1) or success (0) of the converting (refer to system
).
Please download the SWF Tools before using this function: http://www.swftools.org
Yihui Xie
http://animation.yihui.name/animation:start#create_flash_animations
saveMovie
, system
, png
, jpeg
, pdf
## Not run: oopt = ani.options(interval = 0, nmax = 50) # from png saveSWF(knn.ani(test = matrix(rnorm(16), ncol = 2), cl.pch = c(16, 2)), 1.5, dev = "png", para = list(mar = c(3, 3, 1, 1.5), mgp = c(1.5, 0.5, 0)), swfname = "kNN.swf") # from pdf (vector plot!) ani.options(interval = 0, nmax = 50) saveSWF(brownian.motion(pch = 21, cex = 5, col = "red", bg = "yellow"), 0.2, "brownian.swf", "pdf", fmt = "") ani.options(oopt) ## End(Not run)